package com.ruoyi.edge.rule.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.rule.domain.RuleManageChart;
import com.ruoyi.edge.rule.service.RuleManageChartService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 图形计算规则管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/ruleManageChart")
public class RuleManageChartController extends BaseController {

    private final RuleManageChartService ruleManageChartService;

    /**
     * 获取列表
     */
    @SaCheckPermission("edge:ruleManageChart:listPage")
    @GetMapping("/listPage")
    public TableDataInfo<RuleManageChart> listPage(RuleManageChart ruleManageChart, PageQuery pageQuery) {
        return ruleManageChartService.listPage(ruleManageChart, pageQuery);
    }

    /**
     * 获取详情
     */
    @SaCheckPermission("edge:ruleManageChart:get")
    @GetMapping("/get")
    public R<RuleManageChart> get(String id) {
        return ruleManageChartService.get(id);
    }

    /**
     * 新增
     */
    @SaCheckPermission("edge:ruleManageChart:add")
    @PostMapping("add")
    public R<String> add(@RequestBody RuleManageChart ruleManageChart) {
        return ruleManageChartService.add(ruleManageChart);
    }

    /**
     * 编辑
     */
    @SaCheckPermission("edge:ruleManageChart:edit")
    @PutMapping("edit")
    public R<String> edit(@RequestBody RuleManageChart ruleManageChart) {
        return ruleManageChartService.edit(ruleManageChart);
    }

    /**
     * 删除
     */
    @SaCheckPermission("edge:ruleManageChart:remove")
    @DeleteMapping("remove")
    public R<String> remove(String id) {
        return ruleManageChartService.remove(id);
    }
}
